import {
  q as o,
  p as F,
  ap as O,
  X as W,
  f as H,
  H as j,
  av as w,
  aw as q,
  k as u,
  m as d,
  l as p,
  az as G,
  as as i,
  aG as P,
  at as x
} from "./index-30f27935.js";
import { f as C } from "./finance-301595de.js";
function $(D) {
  const m = o([]),
    s = o(!0);
  o({}), F();
  const b = o(1),
    h = o(10),
    t = o([]),
    r = o(),
    S = O("reload"),
    g = W({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    _ = W({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 150 },
      {
        label: "来源用户",
        prop: "source_name",
        minWidth: 150,
        formatter: ({ source_name: e }) =>
          e ||
          u(
            p("el-tag"),
            { class: "mx-1", type: "info", effect: "light" },
            { default: () => [d("暂无")] }
          )
      },
      {
        label: "来源用户手机号",
        prop: "source_phone",
        minWidth: 150,
        formatter: ({ source_phone: e }) =>
          e ||
          u(
            p("el-tag"),
            { class: "mx-1", type: "info", effect: "light" },
            { default: () => [d("暂无")] }
          )
      },
      { label: "收益", prop: "income", minWidth: 120 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) =>
          e == 1
            ? u(
                p("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [d("已发放")] }
              )
            : e == 2
            ? u(
                p("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [d("未发放")] }
              )
            : u(
                p("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [d("暂无")] }
              )
      },
      { label: "类型", prop: "type_name", minWidth: 120 },
      { label: "创建时间", prop: "create_time", minWidth: 180 }
    ],
    I = H(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function z(e) {
    G(e);
  }
  async function J(e) {
    const a = { role_id: e.role_id },
      c = JSON.stringify(a),
      v = { value: i.enc.Base64.stringify(i.enc.Utf8.parse(c)) },
      l = await P(v);
    l.code == 200
      ? (x("删除成功", { type: "success" }), S())
      : x(l.msg, { type: "error" });
  }
  function k() {}
  function L(e) {
    (h.value = e), y(void 0, e);
  }
  function N(e) {
    (b.value = e), y(e, void 0);
  }
  function U(e) {}
  function E(e) {
    (_.text = `正在加载第${e}页...`),
      (s.value = !0),
      w(600).then(() => {
        s.value = !1;
      });
  }
  async function R(e, a = []) {
    (t.value = []),
      a == null ||
        a.map(A => {
          const M = A,
            T = new Date(M);
          t.value.push(
            T.toLocaleDateString("zh-CN", {
              year: "numeric",
              month: "2-digit",
              day: "2-digit"
            })
          );
        }),
      (r.value = e),
      (s.value = !0);
    const c = {
        page: 1,
        pagesize: h.value,
        content: "income",
        user_phone: e.user_phone,
        type: e.type,
        start: t.value[0],
        end: t.value[1]
      },
      f = JSON.stringify(c),
      l = { value: i.enc.Base64.stringify(i.enc.Utf8.parse(f)) },
      { data: n } = await C(l);
    (m.value = n.income.data),
      (g.total = n.income.total),
      setTimeout(() => {
        s.value = !1;
      }, 500);
  }
  async function y(e = b.value, a = h.value) {
    const c = {
        page: e,
        pagesize: a,
        content: "income",
        user_phone: r.value ? r.value.user_phone : void 0,
        type: r.value ? r.value.type : void 0,
        start: t.value[0],
        end: t.value[1]
      },
      f = JSON.stringify(c),
      l = { value: i.enc.Base64.stringify(i.enc.Utf8.parse(f)) },
      n = await C(l);
    n.code === 200
      ? ((m.value = n.data.income.data),
        (g.total = n.data.income.total),
        setTimeout(() => {
          s.value = !1;
        }, 500))
      : x(n.msg, { type: "error" });
  }
  const V = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    j(() => {
      w().then(() => {
        const { setWatermark: e } = q(D.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        y();
    }),
    {
      loading: s,
      columns: B,
      dataList: m,
      pagination: g,
      buttonClass: I,
      formattedDate: t,
      onSearch: R,
      resetForm: V,
      handleaddUser: k,
      handleUpdate: z,
      handleDelete: J,
      handleSizeChange: L,
      handleCurrentChange: N,
      handleSelectionChange: U,
      onCurrentChange: E
    }
  );
}
export { $ as useRole };
